<!--历史数据-->
<template>
  <a-modal
    :visible='visible'
    title="此刻爬跨的牛明细"
    width="100%"
    :footer="null"
    :mask-closable='false'
    :destroy-on-close='true'
    :style="{ top: '0px' }"
    @update:visible='updateVisible'
  >
    <div class="ele-body">
      <!-- 表格 -->
      <div>
        <a-card :bordered="false">
          <ele-pro-table
            ref="table"
            row-key="cattleId"
            :datasource="datasource"
            :columns="columns"
            :where="where"
            :scroll="{ x: 'max-content' }"
          >
            <template #bodyCell="{ column, record }">
              <!-- table操作栏按钮 -->
              <template v-if="column.key === 'action'">
                <a-space>
                  <a-popconfirm title="确定要删除此记录吗？" @confirm="remove(record)">
                    <a class="ele-text-danger">删除</a>
                  </a-popconfirm>
                </a-space>
              </template>
            </template>
          </ele-pro-table>
        </a-card>
      </div>
    </div>
  </a-modal>
</template>

<script>
import {DeviceCattleEstrusRangeApi} from "@/api/property/cattlesports/DeviceCattleEstrusRangeApi";

export default {
  name: 'CattleManagerMonitorEstrusanalysisCattlelist',
  components: {
  },
  props: {
    // 弹窗是否打开
    visible: Boolean,
  },
  emits: ['update:visible'],
  data() {
    return {
      // 表格列配置
      columns: [
        {
          title: '牧场',
          dataIndex: 'oxtallName',
          width: 200,
        },
        {
          title: '牛号',
          dataIndex: 'cattleNo',
          width: 200,
        },
        {
          title: '爬跨开始时间',
          dataIndex: 'beginTime',
        },
        {
          title: '爬跨时间(秒)',
          dataIndex: 'estrusTime',
        }
      ],
      // 表格搜索条件
      where: {
      }
    }
  },
  methods: {
    /**
     * 搜索按钮
     *
     * @author cancan
     * @date 2022/03/05 14:48
     */
    reload() {
      this.selection = [];
      this.$refs.table.reload({page: 1});
    }
    ,

    /**
     * 重置搜索
     *
     * @author cancan
     * @date 2022/03/05 14:48
     */
    reset() {
      this.where.searchBeginTime = '';
      this.where.searchEndTime = '';
      this.$nextTick(() => {
        this.reload();
      });
    },


    /**
     * 获取表格数据
     *
     * @author fengshuonan
     * @date 2022/5/8 15:18
     */
    datasource({page, limit, where, orders}) {
      return DeviceCattleEstrusRangeApi.findeEtrusingCattlePage({...where, ...orders, pageNo: page, pageSize: limit});
    },

    updateVisible(value) {
      this.$emit('update:visible', value);
    }
  }
};
</script>
